load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_oci//oci:defs.bzl", "oci_image")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("//staging/src/kubevirt.io/client-go/version:def.bzl", "version_x_defs")

go_library(
    name = "go_default_library",
    srcs = ["virt-operator.go"],
    importpath = "kubevirt.io/kubevirt/cmd/virt-operator",
    visibility = ["//visibility:private"],
    deps = [
        "//pkg/virt-operator:go_default_library",
    ],
)

go_binary(
    name = "virt-operator",
    embed = [":go_default_library"],
    static = "on",
    visibility = ["//visibility:public"],
    x_defs = version_x_defs(),
)

pkg_tar(
    name = "get-version-tar",
    srcs = ["//:get-version"],
    package_dir = "/",
)

pkg_tar(
    name = "virt-operator-tar",
    srcs = [
        ":virt-operator",
        "//tools/csv-generator",
    ],
    package_dir = "/usr/bin",
)

oci_image(
    name = "version-container",
    base = "//:passwd-image",
    tars = [
        ":get-version-tar",
    ],
)

oci_image(
    name = "virt-operator-image",
    base = ":version-container",
    entrypoint = ["/usr/bin/virt-operator"],
    tars = [
        ":virt-operator-tar",
    ],
    user = "1001",
    visibility = ["//visibility:public"],
)
